package com.staginfo.segs.business;

import android.content.Context;


import com.staginfo.segs.base.BaseManager;
import com.staginfo.segs.common.ApiAsyncTask;
import com.staginfo.segs.common.Constants;

import java.util.LinkedHashMap;

/**
 * 用户管理类
 * Created by Administrator on 2016/7/11 0011.
 */
public class UserManager extends BaseManager {
    private static final String TAG="UserManager";
    public static final int AUTHENTICATE=8001;
    public static final  int MODIFY=8002;
    public static final int LOGOUT=8003;
    public static final int QUERY_USERS=8004;
    public static final int QUERY_USERS_BY_TAG=8005;
    public static final int QUERY_TAGS_BY_USER_ID=8006;
    public static final int QUERY_ID_BY_UUID=8007;

    public static final int LOGIN_SUCCESS=0;
    public static final int USER_LOGIN_FAIL=1;
    public static final int TERMINAL_FAIL=2;
    public static final int TERMINAL_INVAILD=3;
    public static final int TERMINAL_BIND_OTHER = 4;
    public static final int TERMINAL_UNBIND = 5;
    public UserManager(Context context) {
        super(context);
    }

    /**
     * 用户登录
     * @param username
     * @param password
     * @param handler
     */
    public void authenticate(String username,String password,String terminalId,ApiAsyncTask.ApiRequestListener handler){
        LinkedHashMap<String,String> params=new LinkedHashMap<String, String>();
        params.put("username",username);
        params.put("password",password);
        params.put("terminalId", terminalId);
        new ApiAsyncTask(context,AUTHENTICATE,getServiceUrl(),"authenticate",params,handler,true).execute();
    }

    @Override
    protected String getServiceUrl() {
        return getServerUrl()+ Constants.SERVICE_USER;
    }
}
